package com.demo.springmvc.controller;

import com.demo.springmvc.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author liangliang
 */
@Controller
public class HelloWordController {

    private final HelloService service;

    @Autowired
    public HelloWordController(HelloService service) {
        this.service = service;
        System.out.println("HelloWordController Constructor");
    }

    @RequestMapping("helloword")
    public String helloword(Model model) {
        // 登陆之后才可查看，登陆拦截
        model.addAttribute("hello", service.hello());
        return "helloword";
    }

    @RequestMapping(value = "check")
    @ResponseBody
    public String check() {
        return "OK";
    }

}
